{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHAAAABwCAAAAADji6uXAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAF3SURBVGje7dmxSh1BGIbhRxFERYlgCr0BwYild+AFeAykyh1Y2Ztb0Fq0SRMQwfReQCAEFNOksEthClOIgkETTbEDsfHsOXsgzv7MB8ssOwMvLx87s7CUlJSUlJSUlJSUlJQMnqG6BZOYwy88YCw9n8cKZnGHM2z2ABz+34bxgbUddnCAK/zBiyfW/cQSznMzjA8cqVtwr3rPxtLiu0dzO5jBG4ym+9Jhfh1+9K+fNbzHzaP5d2m8xNccDeMDa/fSbpnGN7zEBrZzNIwPHKjDfbzGKZZxm6NhfGDtXtotK2n8orf+nsUwPnCgDuECezkbxgc27vAtplRn4KecDeMDG3e4rjpMP+duGB/YqMNFLLTFMD6wUYcT6fqOw9wN4wMbdTiXxl29f48+m2F8YKMOO2n80AbD+MC+OxzGeLq/aINhfGDfHb5SvYc/8LsNhvGBfXe4qvqPeITrNhjGBzY6D2+x1RbD+MBGHZ7guC2GBViA+QNL2p+/xQEucNxeTvwAAAAASUVORK5CYII=",
      "text/plain": [
       "28×28 reinterpret(Gray{Float32}, ::Array{Float32,2}):\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " ⋮                                                                               ⋱  ⋮                                                         \n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHAAAABwCAAAAADji6uXAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAF5SURBVGje7de/LixxGMbxjxNROBGJxAW4A40cConEn0RouAqKcwEk4gpUeoVSQ0eDTuhQUYiaSJycREEkFLvFRDOzs2Jm3vye6v1tNvPdb568OzOkpKSkpKSk9HzHRf7gDIdYzPnur582jA/s/Y4LrOOjrobxgV13OIKFOhvGB3bd4VJmPqijYXxgVx32YTJzvqmjYXxg6Q57sYX59nkf13U0jA8s/Vw6gOf2fIsJ/K+jYXxg6T1cycznivVXiWF8YKk9HMMx+vEPM7isq2F8YKk9nMFvrXfCNcX7q8QwPrDjDqew2f6lT7iou2F8YEf/pf24wzDeMK7Ys2ilhvGBHe3hqlZ/8Kjz/ioxjA8svIcTONK6Dz5gWrF3+soN4wML7eEQNrT6gx3l+qvEMD6wUIfbmGvPJ9htkmF8YG6HwxjNnPdw3yTD+MDc++EkTr98NoiXphjGB+bu4d8v5yu8N8kwPjC3w2ssZ+ZZvDbJMD4wJSUlJSUlhU+ytCwFOpoS3wAAAABJRU5ErkJggg==",
      "text/plain": [
       "28×28 reinterpret(Gray{Float32}, ::Array{Float32,2}):\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " ⋮                                                                               ⋱  ⋮                                                         \n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAHAAAABwCAAAAADji6uXAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAINSURBVGje7dlPiI1RGAbw3zCRGCV/kpRZyIKFbGXGTlaEhZSa7JQFC0kW0qywExqxkGIpCxsL0pUsrISisPKnyZQ/K0JzLc7R/Ub3u9fMLXM6nae+7ve+557v6enpPfd970dBQUFBQUFBX93CdezDc1yKuVe42yPhnP+tMH/C/rqF12hiA87H3Be8i/cPcRlPU1eYP2FtHc7DbpzD0pqNH3Evxse1/E1KYf6Efd2+cAyLK/F+rI4bm5X8S+zEm9QU5k/Y1cO/sQIjGIrXQGVtAqMYS0lh/oTT9rCKIZzC1hj/whGtHigJhfkT9vey+S2WV+IPOvs3KwrzJ+zJw11YX4mPpqgwf8KePByp3D/C/RQV5k84Yw+HsaoSf45XcgrzJ5xRTzOMBiYruUHh9zE5hfkTTrsOF+Kw4F9T6EVHMZ6qwvwJ/6kOFwh+zRf8OqQ1448LM3+yCvMn7FqHa3EN37XmwCoaMd9IVWH+hLUebsYNoQaXdXjAXszFY3xLUWH+hG3P0gvYYWrf+Qc/hPNzAEsq+bM4kaLC/Anb1uEW7f17gou4ik24jZVxbQ++4kxqCvMnbFuHG3FTmBfe4xZO4qep5+UiHMTpGE8K5+8VYeZPQmH+hLV96Trhv9BPeNHhAQN4ED8HY24CB3AnBYX5E/b03qKKNdguvEPchmfCeTvrCvMnLCgoKCgoKOA3dK9MmBj2wMAAAAAASUVORK5CYII=",
      "text/plain": [
       "28×28 reinterpret(Gray{Float32}, ::Array{Float32,2}):\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " ⋮                                                                               ⋱  ⋮                                                         \n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  …  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)\n",
       " Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)     Gray{Float32}(0.0)  Gray{Float32}(0.0)  Gray{Float32}(0.0)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "3-element Array{UInt8,1}:\n",
       " 0x07\n",
       " 0x01\n",
       " 0x02"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "┌ Info: Loading MNIST...\n",
      "└ @ Main /kuacc/users/dyuret/.julia/dev/Knet/data/mnist.jl:33\n"
     ]
    }
   ],
   "source": [
    "# Take a look at some random images and labels in data\n",
    "using Pkg; for p in (\"Knet\",\"Images\"); haskey(Pkg.installed(),p) || Pkg.add(p); end\n",
    "using Knet,Images,Random\n",
    "include(Knet.dir(\"data\",\"mnist.jl\"))\n",
    "xtrn,ytrn,xtst,ytst = mnist()\n",
    "rp = randperm(10000)\n",
    "for i=1:3; display(mnistview(xtst,rp[i])); end\n",
    "display(ytst[rp[1:3]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Main.MLP"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "include(\"mlp.jl\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "This example learns to classify hand-written digits from the [MNIST](http://yann.lecun.com/exdb/mnist) dataset.  There are 60000 training and 10000 test examples. Each input x consists of 784 pixels representing a 28x28 image.  The pixel values are normalized to [0,1]. Each output y is converted to a ten-dimensional one-hot vector (a vector that has a single non-zero component) indicating the correct class (0-9) for a given image.  10 is used to represent 0.\n",
       "\n",
       "You can run the demo using `julia mlp.jl` on the command line or `julia> MLP.main()` at the Julia prompt.  Options can be used like `julia mlp.jl --epochs 3` or `julia> MLP.main(\"--epochs 3\")`.  Use `julia mlp.jl --help` for a list of options.  The dataset will be automatically downloaded.  By default a softmax model will be trained for 10 epochs.  You can also train a multi-layer perceptron by specifying one or more –hidden sizes.  The accuracy for the training and test sets will be printed at every epoch and optimized parameters will be returned.\n"
      ],
      "text/plain": [
       "  This example learns to classify hand-written digits from the MNIST (http://yann.lecun.com/exdb/mnist) dataset. There are 60000 training and 10000\n",
       "  test examples. Each input x consists of 784 pixels representing a 28x28 image. The pixel values are normalized to [0,1]. Each output y is converted\n",
       "  to a ten-dimensional one-hot vector (a vector that has a single non-zero component) indicating the correct class (0-9) for a given image. 10 is\n",
       "  used to represent 0.\n",
       "\n",
       "  You can run the demo using \u001b[36mjulia mlp.jl\u001b[39m on the command line or \u001b[36mjulia> MLP.main()\u001b[39m at the Julia prompt. Options can be used like \u001b[36mjulia mlp.jl\n",
       "  --epochs 3\u001b[39m or \u001b[36mjulia> MLP.main(\"--epochs 3\")\u001b[39m. Use \u001b[36mjulia mlp.jl --help\u001b[39m for a list of options. The dataset will be automatically downloaded. By\n",
       "  default a softmax model will be trained for 10 epochs. You can also train a multi-layer perceptron by specifying one or more –hidden sizes. The\n",
       "  accuracy for the training and test sets will be printed at every epoch and optimized parameters will be returned."
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "@doc MLP"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "usage: <PROGRAM> [--seed SEED] [--batchsize BATCHSIZE]\n",
      "                 [--epochs EPOCHS] [--hidden [HIDDEN...]] [--lr LR]\n",
      "                 [--winit WINIT] [--fast] [--atype ATYPE]\n",
      "                 [--gcheck GCHECK]\n",
      "\n",
      "mlp.jl (c) Deniz Yuret, 2016. Multi-layer perceptron model on the\n",
      "MNIST handwritten digit recognition problem from\n",
      "http://yann.lecun.com/exdb/mnist.\n",
      "\n",
      "optional arguments:\n",
      "  --seed SEED           random number seed: use a nonnegative int for\n",
      "                        repeatable results (type: Int64, default: -1)\n",
      "  --batchsize BATCHSIZE\n",
      "                        minibatch size (type: Int64, default: 100)\n",
      "  --epochs EPOCHS       number of epochs for training (type: Int64,\n",
      "                        default: 10)\n",
      "  --hidden [HIDDEN...]  sizes of hidden layers, e.g. --hidden 128 64\n",
      "                        for a net with two hidden layers (type: Int64)\n",
      "  --lr LR               learning rate (type: Float64, default: 0.5)\n",
      "  --winit WINIT         w initialized with winit*randn() (type:\n",
      "                        Float64, default: 0.1)\n",
      "  --fast                skip loss printing for faster run\n",
      "  --atype ATYPE         array type: Array for cpu, KnetArray for gpu\n",
      "                        (default: \"KnetArray{Float32}\")\n",
      "  --gcheck GCHECK       check N random gradients per parameter (type:\n",
      "                        Int64, default: 0)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "MLP.main(\"--help\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "mlp.jl (c) Deniz Yuret, 2016. Multi-layer perceptron model on the MNIST handwritten digit recognition problem from http://yann.lecun.com/exdb/mnist.\n",
      "opts=(:batchsize, 100)(:fast, false)(:atype, \"KnetArray{Float32}\")(:epochs, 10)(:gcheck, 0)(:winit, 0.1)(:lr, 0.5)(:hidden, Int64[])(:seed, -1)\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "┌ Info: Loading MNIST...\n",
      "└ @ Main.MLP /kuacc/users/dyuret/.julia/dev/Knet/data/mnist.jl:33\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(:epoch, 0, :trn, 0.08668333333333333, :tst, 0.0859)\n",
      "(:epoch, 1, :trn, 0.9001, :tst, 0.9044)\n",
      "(:epoch, 2, :trn, 0.9077666666666667, :tst, 0.9078)\n",
      "(:epoch, 3, :trn, 0.9113333333333333, :tst, 0.91)\n",
      "(:epoch, 4, :trn, 0.9138333333333334, :tst, 0.9116)\n",
      "(:epoch, 5, :trn, 0.9152166666666667, :tst, 0.9129)\n",
      "(:epoch, 6, :trn, 0.9165, :tst, 0.914)\n",
      "(:epoch, 7, :trn, 0.9175333333333333, :tst, 0.9149)\n",
      "(:epoch, 8, :trn, 0.9185, :tst, 0.915)\n",
      "(:epoch, 9, :trn, 0.9189666666666667, :tst, 0.9159)\n",
      "(:epoch, 10, :trn, 0.9193833333333333, :tst, 0.9164)\n",
      "  7.748784 seconds (8.38 M allocations: 4.267 GiB, 4.67% gc time)\n"
     ]
    }
   ],
   "source": [
    "model = MLP.main(\"\");"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Julia 1.0.0",
   "language": "julia",
   "name": "julia-1.0"
  },
  "language_info": {
   "file_extension": ".jl",
   "mimetype": "application/julia",
   "name": "julia",
   "version": "1.0.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
